/**
 * Copyright (c) 2021 myons Inc. All rights reserved.
 */
package cn.zmwh.common.security.service.factory;

import cn.zmwh.common.core.constants.ServiceConstants;
import cn.zmwh.common.core.exception.RRException;
import cn.zmwh.common.security.base.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @describe: 登录工厂 、
 * @author: dmzmwh 、
 * @time: 2021-12-17 16:55 、
 */
@Component
public class LoginServiceFactory {


    @Autowired
    private Map<String, LoginService> loginServiceMap = new HashMap<>();

    public LoginService loginService(String type) throws Exception {
        String typeName = type + ServiceConstants.LOGIN;
        LoginService payService = loginServiceMap.get(typeName);
        if (payService == null) {
            throw new RRException("该登录类型不存在!");
        }
        return payService;
    }
}
